package database;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class SupermarketLogin extends JFrame {
    private JPanel panel;
    private JTextField usernameField;
    private JPasswordField passwordField;
    private JButton loginButton;
    private JMenuBar menuBar;

    public SupermarketLogin() {
        setTitle("超市管理系统登录");
        setSize(300, 200);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLayout(new BorderLayout());
        setJMenuBar(new JMenuBar());

        panel = new JPanel();
        panel.setLayout(new GridLayout(3, 2, 5, 5));

        // 用户名输入框
        panel.add(new JLabel("用户名:"));
        usernameField = new JTextField(20);
        panel.add(usernameField);

        // 密码输入框
        panel.add(new JLabel("密码:"));
        passwordField = new JPasswordField(20);
        panel.add(passwordField);

        // 登录按钮
        loginButton = new JButton("登录");
        loginButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                // 登录逻辑
                System.out.println("用户名: " + usernameField.getText());
                System.out.println("密码: " + new String(passwordField.getPassword()));
            }
        });
        panel.add(loginButton);

        add(panel, BorderLayout.CENTER);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                new SupermarketLogin().setVisible(true);
            }
        });
    }
}
